<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.store.TaskMgr"%>
<%@page import="com.store.Task"%>
<%@page import="com.tss.util.*"%>
<%@page import="com.store.*"%>
<%@page import="com.jedi.*"%>
<%@include file="../global_var.jsp"%>
<%@page import="java.text.*"%>
<%@ page import="java.awt.geom.Arc2D.Double" %>
<%@include file="../check_login.jsp"%>
<%
	UserMgr userMgr = new UserMgr();
	List userList=null;
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String enddate = new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime());
Calendar calen = Calendar.getInstance();
calen.setTime(TSSDate.parseDate(enddate));
calen.add(Calendar.MONTH, -1);
String begindate = new SimpleDateFormat("yyyy-MM-dd").format(calen.getTime());
User just_user = (User)session.getAttribute("LoginUser");
String power_enable_id = "10212";

if (!just_user.hasPower(power_enable_id)) {
	out.println(strNoPowerInfo); 
	return;
}
TasktimevMgr tasktimevMgr = new TasktimevMgr();
String engineerid     = ParamUtils.getParameter(request,"engineerid","");

List list = null;

String begin_date    = ParamUtils.getParameter(request,"begin_date",begindate);
String end_date      = ParamUtils.getParameter(request,"end_date",enddate);

%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>My JSP 'borrow_list.jsp' starting page</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
	<link href="style/main.css" rel="stylesheet" type="text/css">
		<script language="javascript" src="js/common.js"></script>
<script language="javascript">
function clk_task_show(id) {
	right_menu_clk("task_show.jsp?taskid=" + id);
}
</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<table width="200%" border="0" cellpadding="0" cellspacing="0" align="center">
  <tr>
	 <td >
		<form name="pageForm" method="post">
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td height="100" valign="top" align="center" style="padding-top:12px;padding-bottom:10px;">
								
					<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF">
					<tr bgcolor="#D7D7DB">
						<td height="25" >
                  工程师：
                    <select name="engineerid"  style="width:60px" >
            	        <option value="">全部</option>
            	        <%
            	    	String engineer="engineer";
            	         userList = userMgr.getUsersGroupbyroleid(engineer);
            	        if (userList != null && userList.size() > 0) {
                    		for(int i=0;i<userList.size();i++){
                    			User item = (User)userList.get(i);
                    	%>
                        <option value="<%=item.getId()%>"<%if (item.getId().equals(engineerid)) {%> selected<%}%>><%=item.getUserName()%></option>
                    	<%}}%>
            	      </select>
             登记日期：
                  从 <span id="htmlBeginTime">&nbsp;</span> &nbsp; 至 &nbsp; <span id="htmlEndTime" >&nbsp;</span>
                  <input type="submit" class="inputButton" value="确定">
				</td>
			</tr>
			 <tr bgcolor="#FFFFFF">
					<td height="15" style="padding-left:10px;" colspan="4">
					</td>
					</tr>
			</table>
            <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF">
              <tr align="center" bgcolor="#858585">
                <td width="10%" height="24"><font color="#FFFFFF">项目名称</font></td>
                <td width="9%" height="24"><font color="#FFFFFF">客户名称</font></td>
                <td width="6%"><font color="#FFFFFF">工程师</font></td>
                <td width="9%"><font color="#FFFFFF">出差地点</font></td>
          		<td width="6%"><font color="#FFFFFF">出差方式</font></td>
                <td width="6%"><font color="#FFFFFF">服务内容</font></td>
                <td width="7%"><font color="#FFFFFF">产品方向</font></td>
                <td width="7%"><font color="#FFFFFF">实际开始时间</font></td>
                <td width="7%"><font color="#FFFFFF">实际结束时间</font></td>
                <td width="5%"><font color="#FFFFFF">正常工作量</font></td>
                <td width="5%"><font color="#FFFFFF">加班工作量</font></td>
                  <td width="5%"><font color="#FFFFFF">实际工作量</font></td>
                <td width="5%"><font color="#FFFFFF">合计天数</font></td>
                <td width="8%"><font color="#FFFFFF">差旅费</font></td>
              </tr>
              <%
              String otherSQL = "";
             if (!engineerid.trim().equals("")) otherSQL += " and engineerid = '" + engineerid + "'";
	              if (!begin_date.trim().equals("")) otherSQL += " and substring(t.abegindate for 10) >= '" + begin_date.trim() + "'";
	              if (!end_date.trim().equals("")) otherSQL += " and substring(t.abegindate for 10) <= '" + end_date.trim() + "'";
              String orderField = "t.abegindate desc";
              int pageSize = 8;
            int pageno=1;
               String page2=request.getParameter("mgh");
              		if(page2==null||page2==""){
              				pageno=1;
              				}
              			else{
              					pageno=Integer.parseInt(page2);
              				}
              int pageNo = ParamUtils.getIntParameter(request,"page",pageno);
              	             String pageno1 = String.valueOf(pageNo); 
							session.setAttribute("pageno1",pageno1);
				
              list = tasktimevMgr.get(otherSQL,orderField,pageNo,pageSize);
              int total = tasktimevMgr.getTotal(); 
           	int sumworktime=tasktimevMgr.getSumworktime();
       		int sumacttime=tasktimevMgr.getSumacttime();
       		int sumnormaltime=tasktimevMgr.getSumnormaltime();
       		int sumtotdays=tasktimevMgr.getSumtotdays();
       		double sumtripfee=tasktimevMgr.getSumtripfee();
              boolean b=(total % pageSize ==0);
              int pageCount=b?(total/pageSize):(total/pageSize +1);
              if(pageNo>pageCount){
              	pageNo=pageCount;
              }
              if (list != null && list.size() > 0) {
            	String bgColor[] = {"#EDEDF0","#D7D7DB"};
              	for(int i=0;i<list.size();i++) {
              		Tasktimev item = (Tasktimev)list.get(i);
              %>
         <tr align="center" bgcolor="<%=bgColor[i%2]%>" onMouseOver="this.style.background='#efefef'" onMouseOut="this.style.background='<%=bgColor[i%2]%>'">
                <td height="24">
                <%=item.getPrjname()%></td>
                <td><%=item.getCustomer()%></td>
                <td><%=item.getEngname()%></td>
                <td><%=item.getTaskaddress()%></td>
                <td><%=item.getTriptype()%></td>
                 <td><%=item.getMatterinfo()%></td>
                    <td><%=item.getProductdir()%></td>
                      <td><%=item.getAbegindate()%></td>
                        <td><%=item.getAenddate()%></td>
                          <td><%=item.getNormaltime()%></td>
                            <td><%=item.getWorktime()%></td>
                            <td><%=item.getActtime()%></td>
                             <td><%=item.getTotdays()%></td>
                             
                 <td align="right"><%=FormatNum.formatCurrencycn(item.getTripfee())%></td>
				 </tr>
              <%}%>
              <%
              if(pageNo==pageCount){
              
              %>
               <tr bgcolor="#EDEDF0" height="24">
               <td colspan="2" align="right">
              	合计：
              	</td>
              	<td colspan="7" align="left">
             
              	</td>
              		<td colspan="1" align="center">
              	<%=sumnormaltime%>小时
              	</td>
              	<td colspan="1" align="center">
              	<%=sumworktime%>小时
              	</td>
              		<td colspan="1" align="center">
              	<%=sumacttime%>小时 
              	</td>
              	<td colspan="1" align="center">
              	<%=sumtotdays%>天
              	</td>
              	<td colspan="1" align="right">
              	<%=FormatNum.formatCurrencycn(sumtripfee)%> 
              	</td>
               </tr>
               <%}%>
            </table>
            <table width="100%" border="0" cellpadding="0" cellspacing="0" background="images/page_img/page_bk.gif">
              <tr height="32" align="center" valign="bottom"> 
                <td width="5%">
                 
                </td>
                <td height="35" align="right" style="padding-right:10px;" valign="bottom" id="pannelPageInfo">&nbsp;</td>
              </tr>
            </table>
            <script language="javascript">
            pannelPageInfo.innerHTML = getPageInfo(<%=total%>,<%=pageSize%>,<%=pageNo%>,5,'images/page_img','pageForm');
            </script>
            <%}else{%>
            </table>
            <table width="95%" border="0" cellpadding="4" cellspacing="1" bgcolor="#FFFFFF">
              <tr> 
                <td height="60" align="center">目前没有任何工单信息!</td>
              </tr>
            </table>
            <%}%>
          
          </form>
          </td>
       </tr>
       </table>
      
<script language="javascript">
	htmlBeginTime.innerHTML = showCalenderInput("begin_date","pageForm","<%=begin_date%>",1);
	htmlEndTime.innerHTML = showCalenderInput("end_date","pageForm","<%=end_date%>",1);
</script>
</body>
</html>